package com.yan.demo;

import java.util.Scanner;

public class MethodTest1 {
    public static void main(String[] args) {
        double newMoney = getDiscount();
        System.out.println("打折后的价格为:" + newMoney);
    }

    public static double getDiscount() {
        double newMoney = 0;
        Scanner input = new Scanner(System.in);
        System.out.println("输入机票原价");
        double money = input.nextDouble();
        System.out.println("输入月份");
        int month = input.nextInt();
        if (month < 0 || month > 12) {
            System.err.println("输入的数据不合法！");
        }
        System.out.println("输入机舱类型");
        String EngineRoomType = input.next();
        switch(EngineRoomType) {
            case "经济舱" :
                if(month >= 5 && month <= 10){
                    newMoney = money * 0.85;
                } else {
                    newMoney = money * 0.65;
                }
                break;
            case "头等舱" :
                if(month >= 5 && month <= 10){
                    newMoney = money * 0.9;
                } else {
                    newMoney = money * 0.7;
                }
                break;
            default:
                System.err.println("输入的数据有误");
        }
        return newMoney;
    }


}
